const CompressionPlugin = require('compression-webpack-plugin')
module.exports = {
  devServer: {
    host: '0.0.0.0',
    port: 8081,
    open: true,
    proxy: {
      '/blogapi': {
        target: 'www.baidu.com',
        changeOrigin: true,
        pathRewrite: {
          '^/blogapi/': ''
        }
      }
    }
  },
  configureWebpack: (config) => {
    if (process.env.NODE_ENV === 'production') {
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
      return {
        plugins: [
          new CompressionPlugin({
            test: /\.js$|\.html$|\.css/,
            threshold: 10240,
            deleteOriginalAssets: false
          })
        ]
      }
    }
  },
  publicPath: process.env.VUE_APP_ENV === 'production' ? '/' : '/blog',
  productionSourceMap: false
}
